package com.example.hellodemo.listView;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.hellodemo.R;

public class GrideAdapter extends BaseAdapter {

    private  Context context;
    private LayoutInflater mLayoutInflater;

    public GrideAdapter(Context context){
        this.context = context;
        mLayoutInflater = LayoutInflater.from(context); // 得到布局管理器

    }
    @Override
    public int getCount() {
        return 10;
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    static class ViewHolder{
        public ImageView imageView;
        public TextView  titleView;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder = null;
        if (convertView == null){
            holder = new ViewHolder();
            convertView = mLayoutInflater.inflate(R.layout.gride_item,null);
          holder.imageView =   convertView.findViewById(R.id.gr_img);
          holder.titleView =  convertView.findViewById(R.id.gr_title);
          convertView.setTag(holder);

        }else {
            holder = (ViewHolder)convertView.getTag();
        }
        holder.titleView.setText("测试发送到");
        return convertView;
    }
}
